<?php
$content->assign("formAction", Utils::generateSEOUrl($lang, $section, "save"));

// Options
$contentOptions = array(
	0 => array(
		"text" => "Volver",
		"link" => Utils::generateSEOUrl($lang, $section),
		"icon" => IMAGES_URL."icons/small/white/Home.png"
	),
);
$content->assign("contentOptions", $contentOptions);

$id = $_GET["id"];

$query = "SELECT alias, name, description, keywords, tourId ".
		 "FROM sections ".
		 "WHERE id = '$id'";
if (!$res1 = $db->runQuery($query)) {
	$content->assign("error", "Error de MySQL: ".$db->getErrorDescription());
} else {
	if (!$db->getRowCount($res1)) {
		$content->assign("error", "Se ha producido un error al recuperar la información de la base de datos.");
	} else {
		$row1 = $db->getRow($res1);
		$content->assign("id", $id);
		foreach ($row1 as $key=>$value) {
			if ($key != "tourId") {
				$content->assign($key, utf8_encode($value));
			} else {
				$content->assign("tourId", $value);
				$content->assign("tourInfoDisplay", "none");
				if (!empty($value)) {
					$content->assign("tourInfoDisplay", "block");
					$query = "SELECT summary, content ".
									 "FROM tour_content ".
									 "WHERE tour_id = '$value'";
					$res2 = $db->runQuery($query);
					if ($db->getRowCount($res2)) {
						$row2 = $db->getRow($res2);
						$content->assign("tourSummary", utf8_encode($row2["summary"]));
						$content->assign("tourContent", utf8_encode($row2["content"]));
					}
				}
			}
		}
	}
}
?>
